<template>
	<div class="contentBox">
    <div class="menu">
			<a-breadcrumb style="margin: 0 0 10px 6px; z-index: 2; position: relative">
				<a-breadcrumb-item>
					<router-link :to="{ name: 'teacher' }">{{ t('common', '首页') }}</router-link>
				</a-breadcrumb-item>
				<a-breadcrumb-item>
					{{ projectName }}
				</a-breadcrumb-item>
			</a-breadcrumb>
			<minMenu
				style="flex-shrink: 0"
				:structure="items"
				:messages="state.messages"
			/>
		</div>
    <div class="ai">
      <minAi
        url="/ai/dify/system/chat/chatMessages"
        :hasBg="false"
        containerStyle="box-shadow: none;"
      />
    </div>
  </div>
</template>

<script setup>
import StarBackground from '@/components/StarBackground.vue'
import minHeader from '@/components/common/minHeader.vue'
import { useRoute, useRouter } from 'vue-router'
import { reactive, ref, provide } from 'vue'
import { state, refreshMessages } from '@/stores/info.js'
import { signOut } from '@/request/login.js'
import * as antIcons from '@ant-design/icons-vue'
import learn from '@/router/learn'
import AIConsulting from '@/components/AIConsulting.vue'
import minMenu from '@/components/common/minMenu.vue'
import minAi from '@/components/common/minAi.vue'
import { t } from '@/i18n'

const menusStructure = []
const route = useRoute()
const projectName = ref('')
if (route.query.name && route.query.id)
  sessionStorage.setItem('pojectInfo', JSON.stringify(route.query))
let pojectInfo = JSON.parse(sessionStorage.getItem('pojectInfo') || '{}')
projectName.value =
  route.query.name || projectName.value || pojectInfo.name || ''
provide('pojectInfo', pojectInfo)

refreshMessages(pojectInfo)
const router = useRouter()
const items = ref(
  learn[0].children.map((val) => {
    return {
      path: val.path,
      label: val.meta.title,
      query: route.query,
    }
  })
)
console.log(pojectInfo.type)
if (pojectInfo.type == 'learn') {
  items.value = items.value.filter((val) =>
    ['数据展示', '成员列表', '项目设置'].includes(val.label)
  )
}

const handleMenuClick = (item) => {
  router.push({ path: item.path })
}
const handleOut = async (e) => {
  router.replace('/login')
  localStorage.clear()
  sessionStorage.clear()
  await signOut()
}
</script>

<style lang="scss" scoped>
* {
  min-height: 0;
  min-width: 0;
}

.contentBox {
  display: flex;
  flex-direction: column;
  height: 100%;
	.menu {
		padding: 18px 12px ;
	}
  .ai {
    flex: 1;
  }
}
</style>
